package com.example.controller;

import com.example.entity.User;
import com.example.service.impl.UserServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    UserServiceImpl userService;

    @GetMapping("/findById")
    User findById(String id) {
        return userService.findById(id);
    }
    @GetMapping("/findAll")
    List<User> findAll() {
        return userService.findAll();
    }
    @PostMapping("/save")
    void save(User user) {
        userService.save(user);
    }
    @PostMapping("/update")
    void update(User user) {
        userService.update(user);
    }

    @PostMapping("/delete")
    void delete(String id) {
        userService.delete(id);
    }

}
